package com.example.myapplication;

import android.app.Activity;
import android.os.Bundle;
import com.example.myapplication.until.Globals;
import com.example.myapplication.until.ImageUtils;
import com.example.myapplication.until.JBoxUtils;
import com.example.myapplication.view.MainView;

public class MainActivity extends Activity {

    private MainView mainView ;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //工具类初始化
        Globals.init(this) ;
        ImageUtils.init(this);

        setContentView(R.layout.activity_main);
        mainView = (MainView) findViewById(R.id.main_view) ;

        Thread t = new Thread(){
            public void run(){
                while(true){
                    try{
                        JBoxUtils.world.step(1.0f / 30, 3, 8);
                        mainView.postInvalidate();
                        Thread.sleep(33);
                    }catch(Exception e){
                        e.printStackTrace();
                    }
                }
            }
        } ;
        t.start();
        //重绘
    }
}